package com.mtbu.servlet.sys;
import java.util.Timer;

import javax.servlet.ServletContextEvent;
import javax.servlet.ServletContextListener;

import org.slf4j.Logger;
import org.slf4j.*;

public class MyListener implements ServletContextListener {
	private static Timer timer;
	private static Logger logger = LoggerFactory.getLogger(MyListener.class);
	public void contextDestroyed(ServletContextEvent event) {
		if (timer != null) {
			timer.cancel();
		}
		logger.info("MyListener end ----------------------");
	}

	public void contextInitialized(ServletContextEvent event) {
		logger.info("MyListener start ----------------------");
		long period= 4*60*1000;
		
		timer = new Timer(true);
		timer.schedule(new MyTask(), 0,period);
		logger.info("********************load data by timer********************");
	}
}
 